import axios from '@/api/fetch';
import SERVER from '@/api/server';
// 批量清空库位
export const clearStoragePositionAll = params => axios.post(`${SERVER.DMSCLOUD_PART}/stockmanage/partmanage/clearStoragePositionAll`, params);
// 获取库存列表
export const getpartStocksList = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks`, { params });
// 获取库存列表
export const getpartStocksListRepair = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/repair`, { params });
// 获取库存列表
export const getpartStocksListRepairMain = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/repairReplace`, { params });
// 获取地点
export const getDealertCode = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/DealertCode`, { params });
// 获取仓库
export const getfindStorageCode = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/findUserControlStorageCode`, { params });
// 获取部件组代码
export const getquerypartGroupCodes = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/querypartGroupCodes`, { params });
// 获取备件基本信息列表
export const getpartInfos = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partInfos`, { params });
// 查询单个备件信息
export const querypartInfo = (PART_NO, params) => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/t2/${PART_NO}`, { params });
// 备件库存新增
export const newBuild = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/partinster`, { params });
// 修改
export const edit = (PART_NO, STORAGE_CODE, params) => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/${PART_NO}/${STORAGE_CODE}`, { params });
// 保存
export const save = params => axios.put(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/save`, params);
// 获取出入库记录
export const getStockQuantity = (PART_NO, STORAGE_CODE, params) => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/queryStockQuantity/${PART_NO}/${STORAGE_CODE}`, { params });
export const getStockOutInQuantity = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/queryStockQuantity/${params.partNo}/${params.storageCode}`, { params });
// 获取未被使用的库位
export const getPosition = params => axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partmanage/queryLocations`, { params });
// 清空库位
export const clearPartLocation = (partNo, storageCode) => axios.delete(`${SERVER.DMSCLOUD_PART}/stockmanage/partmanage/clearStoragePosition/${partNo}/${storageCode}`);
// 保存备件信息
export const savePartInfo = params => axios.put(`${SERVER.DMSCLOUD_PART}/basedata/partInfos`, params);
// 根据备件代码和仓库代码查询可用库位
export const queryUsableLocations = params => axios.get(`${SERVER.DMSCLOUD_PART}/partMove/queryLocations`, { params });

// 执行月结
export const handletableOne = params => axios.get(`${SERVER.DMSCLOUD_PART}/pGenPartPeriodTask/executeTaskByUser`);

export const handletableTwo = params => axios.get(`${SERVER.DMSCLOUD_PART}/pGenPartMonreportTask/executeTaskByUser`);
// 月结临时接口给
export const monthStatement = params => axios.get(`${SERVER.DMSCLOUD_PART}/pGenPartMonreportTask`, { params });

export const getpartStocksRepair = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/queryPartInfos`, { params });
//查询总成本金额和数量
export const getAllInfo = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/getAllInfo`, { params });
//导出库位更换模板
export const exportLocationModel = params => {
  return axios({
    url: `${SERVER.DMSCLOUD_PART}/stockmanage/partmanage/exportLocationModel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
